package service

import (
	"gin_gorm_oj/help"
	"gin_gorm_oj/modles"
	"github.com/gin-gonic/gin"
	"strconv"
)

func GetVideoListByAuthor(c *gin.Context) {
	var videoList []modles.Video
	author, _ := strconv.Atoi(c.Query("author"))
	err := modles.DB.Where("author=?", author).Find(&videoList).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  err.Error(),
		})
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  videoList,
	})
}

func PostVideo(c *gin.Context) {
	addr := c.PostForm("addr")
	help.ALiYunOss(addr)
	c.JSON(200, gin.H{
		"code": 200,
	})
}
